package com.ruoyi.web.controller.facilities;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.facilities.domain.TfWatergc;
import com.ruoyi.facilities.service.ITfWatergcService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 废水治理设施Controller
 * 
 * @author yxf
 * @date 2021-08-10
 */
@RestController
@RequestMapping("/facilities/water")
public class TfWatergcController extends BaseController
{
    @Autowired
    private ITfWatergcService tfWatergcService;

    /**
     * 查询废水治理设施列表
     */
    @PreAuthorize("@ss.hasPermi('facilities:water:list')")
    @GetMapping("/list")
    public TableDataInfo list(TfWatergc tfWatergc)
    {
        startPage();
        List<TfWatergc> list = tfWatergcService.selectTfWatergcList(tfWatergc);
        return getDataTable(list);
    }

    /**
     * 导出废水治理设施列表
     */
    @PreAuthorize("@ss.hasPermi('facilities:water:export')")
    @Log(title = "废水治理设施", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TfWatergc tfWatergc)
    {
        List<TfWatergc> list = tfWatergcService.selectTfWatergcList(tfWatergc);
        ExcelUtil<TfWatergc> util = new ExcelUtil<TfWatergc>(TfWatergc.class);
        return util.exportExcel(list, "废水治理设施数据");
    }

    /**
     * 获取废水治理设施详细信息
     */
    @PreAuthorize("@ss.hasPermi('facilities:water:query')")
    @GetMapping(value = "/{wtfId}")
    public AjaxResult getInfo(@PathVariable("wtfId") Long wtfId)
    {
        return AjaxResult.success(tfWatergcService.selectTfWatergcById(wtfId));
    }

    /**
     * 新增废水治理设施
     */
    @PreAuthorize("@ss.hasPermi('facilities:water:add')")
    @Log(title = "废水治理设施", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TfWatergc tfWatergc)
    {
        return toAjax(tfWatergcService.insertTfWatergc(tfWatergc));
    }

    /**
     * 修改废水治理设施
     */
    @PreAuthorize("@ss.hasPermi('facilities:water:edit')")
    @Log(title = "废水治理设施", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TfWatergc tfWatergc)
    {
        return toAjax(tfWatergcService.updateTfWatergc(tfWatergc));
    }

    /**
     * 删除废水治理设施
     */
    @PreAuthorize("@ss.hasPermi('facilities:water:remove')")
    @Log(title = "废水治理设施", businessType = BusinessType.DELETE)
	@DeleteMapping("/{wtfIds}")
    public AjaxResult remove(@PathVariable Long[] wtfIds)
    {
        return toAjax(tfWatergcService.deleteTfWatergcByIds(wtfIds));
    }
}
